<?php
namespace app\api\model;
use think\Model;
class Ordermaster extends Model
{
    public function index()
    {   
       
    }

    public function insertyzfOrder($token,$beizhu,$totalPrice,$servicetime)
    {
         $data = [
            'bianhao'=>time(),
            'token'=>$token,
            'status'=>1,
            'beizhu'=>$beizhu,
            'totalPrice'=>$totalPrice,
            'servicetime'=>$servicetime,
            'pay'=>1,
            'zhuangtai'=>1,
            'post'=>1
         ];
         $id = model('ordermaster')->insertGetId($data);
         return $id;
    }
 
     public function insertwzfOrder($token,$beizhu,$totalPrice,$servicetime)
    {
         $data = [
            'bianhao'=>time(),
            'token'=>$token,
            'status'=>-1,
            'beizhu'=>$beizhu,
            'totalPrice'=>$totalPrice,
            'servicetime'=>$servicetime,
            'pay'=>1,
            'zhuangtai'=>1,
            'post'=>1
         ];
         $id = model('ordermaster')->insertGetId($data);
         return $id;
    }

    public function getOrders($token)
    {
        $data = [
           'token'=>$token,
           'zhuangtai'=>1,  
        ];
        $result = model('ordermaster')
                         ->field("id,bianhao,status,zhuangtai,totalPrice")
                         ->where($data)
                         ->select();
          return $result;
    }

    public function getDzfOrders($token)
    {
           $data = [
             'zhuangtai'=>1,
             'status'=>-1,
             'token'=>$token,
            ];
        return $result = model('ordermaster')
                         ->field("id,bianhao,status,zhuangtai,totalPrice")
                         ->where($data)
                         ->select();
    }

    public function getDfhOrders($token)
    {
           $data = [
             'zhuangtai'=>1,
             'status'=>1,
             'token'=>$token,
            ];
        return $result = model('ordermaster')
                         ->field("id,bianhao,status,zhuangtai,totalPrice")
                         ->where($data)
                         ->select();
    }
    public function getYfhOrders($token)
    {
           $data = [
             'zhuangtai'=>1,
             'status'=>0,
             'token'=>$token,
            ];
        return $result = model('ordermaster')
                         ->field("id,bianhao,status,zhuangtai,totalPrice")
                         ->where($data)
                         ->select();
    }
   public function getYwcOrders($token)
    {
           $data = [
             'zhuangtai'=>1,
             'status'=>2,
             'token'=>$token,
            ];
        return $result = model('ordermaster')
                         ->field("id,bianhao,status,zhuangtai,totalPrice")
                         ->where($data)
                         ->select();
    }
    public function payOrder($oid,$servicetime)
    {
       $count = model('ordermaster')->where('id',$oid)->update(['status'=>1,'servicetime'=>$servicetime]);
        return  $count;
    } 

}